<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <script>
        window.onload = function(){
            function onKeyboardEvnet(evnet){
                console.log(event)
                switch (evnet.keyCode){
                    case 37:
                        console.log('left')
                        break
                    case 38:
                        console.log('up')
                        break
                    case 39:
                        console.log('right')
                        break
                    case 40:
                        console.log('down')
                }
            }

            window.addEventListener('keydown', onKeyboardEvnet,false)
        }    
    </script>
</body>
</html>